import java.util.Scanner;

public class demo7 {
    static class Counter{
        public volatile int flag = 0;
    }

    public static void main(String[] args) {
        Counter counter = new Counter();
        Thread t1 = new Thread(()->{
            while(counter.flag==0){

            }
            System.out.println("循环结束！");
        });
        Thread t2 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            counter.flag = scanner.nextInt();
        });
        t1.start();
        t2.start();
    }
}
